//
//  CoordinateTransform.c
//  MapGisBusiness
//
//  Created by 罗亮富 on 2018/12/20.
//  Copyright © 2018年 Roen. All rights reserved.
//

#include "CoordinateTransform.h"

CLLocationCoordinate2D GpsCoordinateFromCoordinate(CLLocationCoordinate2D cord, LACoordinateSystem sys) {
    
    if(sys == LACoordinateSystemWGS84)
        return cord;
    else if(sys == LACoordinateSystemGCJ02){
        return cl_gcj02ToWgs84(cord.latitude,cord.longitude,false);
    }
    else if(sys == LACoordinateSystemBD09){
        return cl_bd09ToWgs84(cord.latitude,cord.longitude);
    }
    else if(sys == LACoordinateSystemGCJ02GaoDe){
        return cl_gcj02ToWgs84(cord.latitude,cord.longitude,true);
    }
    
    return cord;
}

CLLocationCoordinate2D mapCoordinateFromGpsCoordinate(CLLocationCoordinate2D gpsCord, LACoordinateSystem sys) {
    if(sys == LACoordinateSystemWGS84)
        return gpsCord;
    else if(sys == LACoordinateSystemGCJ02){
        return cl_wgsToGcj02(gpsCord.latitude,gpsCord.longitude,false);
    }
    else if(sys == LACoordinateSystemBD09){
        return cl_wgs84ToBd09(gpsCord.latitude,gpsCord.longitude);
    }
    else if(sys == LACoordinateSystemGCJ02GaoDe){
        return cl_wgsToGcj02(gpsCord.latitude,gpsCord.longitude,true);
    }
    
    return gpsCord;
}
